package cn.zhouixi.ws.controller;
import cn.zhouixi.ws.pojo.User;
import cn.zhouixi.ws.utils.RedisUtils;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    RedisUtils redisUtils;

    @RequestMapping("/{userId}")
    public void test(@PathVariable Long userId) {
        User user = new User(userId);
        String jsonStr = JSON.toJSONString(user);
        redisUtils.convertAndSend("TOPIC_USERNAME", jsonStr);
    }
}
